<template>
  <div
    class="app-container"
    v-loading.fullscreen.lock="loading"
    element-loading-text="Loading"
    element-loading-spinner="el-icon-loading"
    element-loading-background="rgba(0, 0, 0, 0.7)"
    element-loading-customClass="mask"
  >
    <!-- 顶部信息栏开始 -->
    <section
      style="margin: 0; border-bottom: 1px solid #d8d8d8; display: flex"
      ref="topInfo"
    >
      <div style="background-color: #f8f8f8; width: 15%">
        <div class="headerContent">
          <span
            class="extendedHeader name"
            :title="
              dataInfo.name +
                (dataFormat('policyid', dataInfo.policyid).indexOf('文档') > -1
                  ? '-' + dataInfo.title
                  : '')
            "
          >
            <img
              v-if="
                dataFormat('policyid', dataInfo.policyid).indexOf('文档') > -1
              "
              src="/static/image/iconSmallDocument.gif"
              alt=""
            />
            名称：{{ dataInfo.name }}
            <template
              v-if="
                dataFormat('policyid', dataInfo.policyid).indexOf('文档') > -1
              "
            >
              <br />
              <img
                v-if="
                  dataFormat('policyid', dataInfo.policyid).indexOf('文档') > -1
                "
                src="/static/image/iconSmallDocument.gif"
                alt=""
                style="opacity: 0"
              />
              标题：{{ dataInfo.title }}
            </template>
          </span>
          <!-- <span class="extendedHeader name">
            <img v-if="dataFormat('policyid',dataInfo.policyid).indexOf('文档')>-1" src="/static/image/iconSmallDocument.gif" alt="" style="opacity: 0;">
            标题：{{dataInfo.title}}
          </span> -->
        </div>
      </div>
      <div style="width: 85%">
        <div class="headerContent">
          <el-row class="inline-block">
            <span class="extendedHeader content">状态：</span>
            <span class="extendedHeader content">
              {{ dataFormat('stateid', dataInfo.stateid) }}
            </span>
          </el-row>
          <el-row
            class="inline-block"
            v-if="$route.query.type != 'projectdefine/template'"
          >
            <span class="extendedHeader content">所有者：</span>
            <span class="extendedHeader content">
              {{ dataFormat('ownerid', dataInfo.ownerid) }}
            </span>
          </el-row>
          <el-row class="inline-block">
            <span
              class="extendedHeader content"
              v-if="$route.query.type != 'projectdefine/template'"
            >
              版本：
            </span>
            <span class="extendedHeader content">
              {{ dataInfo.revision }}
            </span>
          </el-row>
          <el-row class="inline-block">
            <span class="extendedHeader content">修改日期：</span>
            <span class="extendedHeader content">
              {{ dataInfo.modifyTime }}
            </span>
          </el-row>
        </div>
      </div>
    </section>
    <!-- 顶部信息栏结束 -->
    <!-- 内容主体开始 -->
    <el-button
      v-if="!show"
      class="collapesbutton"
      type="primary"
      plain
      style="left: 0; top: 100px; height: 10%;"
      @click="show = true"
    >
      <i class="el-icon-d-arrow-right"></i>
    </el-button>
    <!--     :style="'height: calc(100% - ' + dif + 'px); margin: 0; width: 100%'" -->
    <section
      :style="'height: calc(100% - ' + dif + 'px); margin: 0; width: 100%'"
    >
      <!-- 侧边栏开始 -->
      <div
        style="width: calc(15% - 6px); float: left"
        class="treeMenu"
        v-show="show"
      >
        <el-button
          class="collapesbutton"
          type="primary"
          plain
          style="right: 1px; top: 50px; height: 10%"
          @click="show = false"
        >
          <i class="el-icon-d-arrow-left"></i>
        </el-button>
        <el-tabs type="border-card" v-model="activeName">
          <el-tab-pane
            name="treeMenu"
            v-if="treeMenu.length > 1"
            style="padding: -15px"
          >
            <span slot="label"><i class="el-icon-tickets"></i></span>
            <el-menu
              style="padding: 0"
              :default-active="activeIndex"
              class="el-menu-vertical"
            >
              <el-menu-item
                v-for="(item, i) in treeMenu"
                :key="i"
                :index="i.toString()"
                @click="handleOpen(item, i)"
              >
                <i :class="item.icon"></i>
                <span slot="title" :title="item.name">{{ item.name }}</span>
              </el-menu-item>
            </el-menu>
          </el-tab-pane>
          <el-tab-pane
            name="treeData"
            v-if="treeData.length > 0"
            style="padding: -15px"
          >
            <span slot="label">
              <svg-icon icon-class="tree-table" />
            </span>
            <dynamic-tree
              ref="dynamicTree"
              :treeData="treeData"
              @handleNodeClick="handleNodeClick"
            >
            </dynamic-tree>
          </el-tab-pane>
        </el-tabs>
      </div>
      <!-- 侧边栏结束 -->

      <resize-bar v-show="show" />

      <div
        style="
          min-width: 75%;
          max-width: 95%;
          padding: 10px 10px 0;
          height: 100%;
          width: 85%;
          float: right;
          box-sizing: border-box;
          overflow: auto;
        "
        :class="show ? '' : 'max-size'"
      >
        <div class="mainContent">
          <template v-if="chart == 'monitor'">
            <el-tabs type="border-card" style="height: 100%">
              <el-tab-pane label="阶段门">
                <stage-gate :geturl="menuUrl" :table="table" />
              </el-tab-pane>
              <el-tab-pane label="甘特图">
                <gantt-chart />
              </el-tab-pane>
            </el-tabs>
          </template>
          <template v-else-if="chart != 'lifeCycle'">
            <!-- <report/> -->
            <component :is="chart"></component>
          </template>
          <template v-if="portal">
            <portal-view :params="portal" :root="this" />
          </template>
          <template v-else>
            <el-row v-if="formData.length > 0" class="mb10" ref="formList">
              <el-col v-if="this.taskid > 0">
                <process-review
                  :collapse="false"
                  :parent="this"
                ></process-review>
                <el-divider></el-divider>
              </el-col>
              <el-col>
                <!-- <template
                  v-if="
                    dataFormat('typeid', dataInfo.typeid) != 'ACAD 工程图' &&
                    dataFormat('typeid', dataInfo.typeid) != 'SW 绘图' &&
                    (dataFormat('stateid', dataInfo.stateid) == '创建'||
                    dataFormat('stateid', dataInfo.stateid) == '工作中')
                  "
                > -->
                <template
                  v-if="
                    dataFormat('typeid', dataInfo.typeid) != 'ACAD 工程图' &&
                      dataFormat('typeid', dataInfo.typeid) != 'SW 绘图' &&
                      (!dataInfo.stateid ||
                        $store.state.optionInfo.States.filter(
                          item =>
                            item.sort == 1 && item.policyid == dataInfo.policyid
                        )[0].id == dataInfo.stateid)
                  "
                >
                  <el-button
                    v-if="!updateShow"
                    style="margin-bottom: 10px"
                    type="success"
                    icon="el-icon-edit"
                    size="mini"
                    @click="updateShow = true"
                    >修改</el-button
                  >
                  <div v-if="updateShow" style="margin-bottom: 10px">
                    <el-button
                      type="primary"
                      icon="el-icon-circle-check"
                      size="mini"
                      @click="handleSaveForm"
                      >保存</el-button
                    >
                    <el-button
                      type="info"
                      icon="el-icon-refresh"
                      size="mini"
                      @click="handleCancelForm"
                      >取消</el-button
                    >
                  </div>
                  <template v-if="menuDataInfo.isWorkflowStart">
                    <el-button
                      v-if="menuDataInfo.isWorkflowStart == 'notStart'"
                      v-show="isMyobject"
                      style="margin-bottom: 10px"
                      type="primary"
                      size="mini"
                      @click="startWorkflow"
                    >
                      启动流程
                    </el-button>
                    <template v-if="menuDataInfo.isWorkflowStart == 'hasStart'">
                      <el-button
                        v-show="isMyobject"
                        style="margin-bottom: 10px"
                        type="danger"
                        size="mini"
                        @click="recallWorkflow('recall')"
                      >
                        回收流程
                      </el-button>
                      <el-button
                        v-show="isMyobject"
                        style="margin-bottom: 10px"
                        type="danger"
                        size="mini"
                        @click="recallWorkflow('cancel')"
                      >
                        取消流程
                      </el-button>
                    </template>
                  </template>
                </template>
              </el-col>
              <el-col
                class="flex"
                v-for="(formItem, index) in formData"
                :key="index"
              >
                <template v-if="index % 2 == 0">
                  <span class="extendedMain fromTitle">
                    {{ formItem.name }}：
                  </span>
                  <div class="extendedMain content" v-if="updateShow">
                    <dynamic-form-Item
                      :addform="[formItem]"
                      :form="menuDataInfo"
                    ></dynamic-form-Item>
                  </div>
                  <span
                    v-else
                    class="extendedMain content"
                    :title="
                      formItem.prop == 'classfication'
                        ? menuDataInfo[formItem.prop]
                        : dataFormat(
                            formItem.componentType == 'el-add-existing' &&
                              formItem.show.indexOf('{') !=
                                formItem.show.lastIndexOf('{') &&
                              formItem.show.indexOf('split_tree_table') == -1
                              ? formItem.prop + '_' + menuDataInfo.projectid
                              : formData[index].prop,
                            menuDataInfo[formItem.prop]
                          )
                    "
                    v-html="
                      dataFormat(
                        formItem.componentType == 'el-add-existing' &&
                          formItem.show.indexOf('{') !=
                            formItem.show.lastIndexOf('{') &&
                          formItem.show.indexOf('split_tree_table') == -1
                          ? formItem.prop + '_' + menuDataInfo.projectid
                          : formData[index].prop,
                        menuDataInfo[formItem.prop]
                      )
                    "
                  >
                    <!-- {{dataFormat(formItem.prop,menuDataInfo[formItem.prop])}} -->
                  </span>
                  <template v-if="index != formData.length - 1">
                    <span class="extendedMain fromTitle">
                      {{ formData[index + 1].name }}：
                    </span>
                    <div class="extendedMain content" v-if="updateShow">
                      <dynamic-form-Item
                        :addform="[formData[index + 1]]"
                        :form="menuDataInfo"
                      ></dynamic-form-Item>
                    </div>
                    <span
                      v-else
                      class="extendedMain content"
                      :title="
                        formData[index + 1].prop == 'classfication'
                          ? menuDataInfo[formData[index + 1].prop]
                          : dataFormat(
                              formData[index + 1].componentType ==
                                'el-add-existing' &&
                                formData[index + 1].show.indexOf('{') !=
                                  formData[index + 1].show.lastIndexOf('{') &&
                                formData[index + 1].show.indexOf(
                                  'split_tree_table'
                                ) == -1
                                ? formData[index + 1].prop +
                                    '_' +
                                    menuDataInfo.projectid
                                : formData[index + 1].prop,
                              menuDataInfo[formData[index + 1].prop]
                            )
                      "
                      v-html="
                        dataFormat(
                          formData[index + 1].componentType ==
                            'el-add-existing' &&
                            formData[index + 1].show.indexOf('{') !=
                              formData[index + 1].show.lastIndexOf('{') &&
                            formData[index + 1].show.indexOf(
                              'split_tree_table'
                            ) == -1
                            ? formData[index + 1].prop +
                                '_' +
                                menuDataInfo.projectid
                            : formData[index + 1].prop,
                          menuDataInfo[formData[index + 1].prop]
                        )
                      "
                    >
                      <!-- {{
                        dataFormat(
                          formData[index + 1].prop,
                          menuDataInfo[formData[index + 1].prop]
                        )
                      }} -->
                    </span>
                  </template>
                  <template v-if="index == formData.length - 1">
                    <span class="extendedMain fromTitle"></span>
                    <span class="extendedMain content"></span>
                  </template>
                </template>
              </el-col>
              <el-col v-if="photo && dataInfo[photo]">
                <el-image
                  v-for="item of JSON.parse(dataInfo[photo])"
                  :key="item.id"
                  :src="item.path"
                  lazy
                ></el-image>
              </el-col>
            </el-row>
            <template v-if="chart == 'lifeCycle'">
              <life-cycle
                :geturl="menuUrl"
                :parent="this"
                :options="lifeCycleOptions"
                ref="lifeCyle"
              ></life-cycle>
            </template>
            <template v-if="chart != 'monitor'">
              <el-row :gutter="10" class="mb8">
                <el-col :span="1.5">
                  <div
                    v-for="(toolbar, index) in toolbarData"
                    :key="index"
                    style="display: inline-block"
                  >
                    <template
                      v-if="
                        (toolbar.info.display == 0 &&
                          toolbar.data.length >= 4) ||
                          toolbar.info.display == 2
                      "
                    >
                      <el-dropdown
                        placement="bottom-start"
                        style="
                          padding: 0;
                          margin-right: 10px;
                          margin-left: 10px;
                        "
                      >
                        <el-button type="primary" size="mini">
                          <i :class="toolbar.info.icon"></i>
                          {{ toolbar.info.description }}
                          <i class="el-icon-arrow-down"></i>
                        </el-button>
                        <el-dropdown-menu slot="dropdown">
                          <el-dropdown-item
                            v-for="(btn, key) in toolbar.data.filter(
                              item =>
                                item.status === '1' && item.location === '2'
                            )"
                            :key="key"
                          >
                            <el-button
                              size="mini"
                              type="text"
                              :icon="btn.icon"
                              @click="clickEvent(btn)"
                              :disabled="
                                btn.show != null &&
                                btn.show != undefined &&
                                btn.show != ''
                                  ? !dynamicEval($data, btn.show)
                                  : false
                              "
                              v-preventReClick
                              >{{ btn.name }}</el-button
                            >
                          </el-dropdown-item>
                        </el-dropdown-menu>
                      </el-dropdown>
                    </template>
                    <template
                      v-if="
                        (toolbar.info.display == 0 &&
                          toolbar.data.length < 4) ||
                          toolbar.info.display == 1
                      "
                    >
                      <div
                        v-for="(btn, index) in toolbar.data"
                        :key="index"
                        style="display: inline-block; margin: 0 3px"
                      >
                        <template
                          v-if="btn.name == '全编辑' && getEditForm(btn.url)"
                        >
                          <el-button
                            v-if="!editall"
                            :type="btn.styleType"
                            :icon="btn.icon"
                            size="mini"
                            @click="clickEvent(btn)"
                            >{{ btn.name }}
                          </el-button>
                          <el-button
                            type="primary"
                            size="mini"
                            @click="subEditAll()"
                            v-if="editall"
                            >保存</el-button
                          >
                          <el-button
                            type="info"
                            size="mini"
                            @click="cancelEditAll()"
                            v-if="editall"
                            >取消</el-button
                          >
                        </template>
                        <template v-else>
                          <el-button
                            v-if="btn.status === '1' && btn.location === '2'"
                            :type="btn.styleType"
                            :icon="btn.icon"
                            size="mini"
                            @click="clickEvent(btn)"
                            :disabled="
                              btn.show != null &&
                              btn.show != undefined &&
                              btn.show != ''
                                ? !dynamicEval($data, btn.show)
                                : false
                            "
                            v-preventReClick
                            >{{ btn.name }}
                          </el-button>
                        </template>
                      </div>
                    </template>
                  </div>
                </el-col>
                <!-- 列筛选 -->
                <el-popover
                  v-if="columns.length > 0 && chart != 'lifeCycle'"
                  title="列筛选"
                  trigger="click"
                  style="float: right; margin-right: 10px"
                >
                  <el-checkbox
                    style="display: block"
                    v-for="(item, index) in columns"
                    :key="index"
                    :label="item.name"
                    v-model="item.show"
                    >{{ item.name }}
                  </el-checkbox>
                  <el-button size="small" slot="reference">
                    <i class="el-icon-arrow-down el-icon-menu"></i>
                  </el-button>
                </el-popover>
                <!-- 列筛选 -->
              </el-row>
              <template v-if="columns.length > 0">
                <!--列表数据-->
                <dynamic-tree-table
                  ref="treeTable"
                  v-if="type == 'tree_table'"
                  :list="tableData"
                  @ContextMenu="Opencontextmenu($event)"
                  @handleSelectionChange="handleSelectionChange"
                  @editChanged="editChanged($event)"
                  @openTable="openTable($event)"
                  @SetFlag="SetFlag()"
                  :options="options"
                  :columns="columns"
                  :operates="operates"
                  :flag="flag"
                  :diff="diff"
                >
                </dynamic-tree-table>
                <template v-else>
                  <dynamic-table
                    ref="dyTable"
                    :list="tableData"
                    @updateList="getConfig"
                    @handleSelectionChange="handleSelectionChange"
                    @editChanged="editChanged($event)"
                    @openTable="openTable($event)"
                    @handleNodeClick="handleNodeClick"
                    :options="options"
                    :columns="columns"
                    :operates="operates"
                    :diff="diff"
                  >
                  </dynamic-table>
                  <pagination
                    v-show="total > 0"
                    :total="total"
                    :page.sync="queryParams.pageNum"
                    :limit.sync="queryParams.pageSize"
                    @pagination="getList"
                    ref="pagination"
                  />
                </template>
              </template>
            </template>
          </template>
        </div>
      </div>
    </section>
    <!-- 内容主体结束 -->

    <!-- 自定义右键菜单开始 -->
    <ul
      v-show="contextmenu.visible"
      :style="{ left: contextmenu.left + 'px', top: contextmenu.top + 'px' }"
      class="contextmenu"
    >
      <template
        v-if="
          this.ids.length > 0 &&
            this.tableData &&
            this.tableData.length <= this.copy_table.length
        "
      >
        <li @click="copy('copy')">复制所选项及所有子项</li>
        <li @click="copy('cut')">剪切所选项及所有子项</li>
        <template v-if="this.copy_ids.length > 0">
          <li @click="paste(1)">粘贴为子项</li>
          <li @click="paste(0)">粘贴为同级</li>
        </template>
      </template>
      <li
        v-if="
          this.ids.length <= 0 &&
            this.tableData &&
            this.tableData.length <= this.copy_table.length
        "
      >
        未选中任何数据
      </li>
      <template
        v-if="this.tableData && this.tableData.length > this.copy_table.length"
      >
        <li @click="submit()">保存编辑</li>
        <li @click="reset()">重置</li>
      </template>
    </ul>
    <!-- 自定义右键菜单结束 -->

    <!-- 一级添加或修改对话框开始 -->
    <el-dialog
      ref="addForm"
      :title="title"
      :visible.sync="open"
      width="50%"
      v-dialogDrag
      :close-on-click-modal="false"
      v-if="open"
    >
      <dynamic-form
        :addform="addFormData"
        :form="form"
        :rules="rules"
        :addurl="addurl"
        @loadingOpen="handleLoadingOpen"
        @loadingClose="loading = false"
        v-on:openChanged="openChanged"
      >
      </dynamic-form>
    </el-dialog>
    <!-- 一级添加或修改对话框结束 -->

    <!-- 一级表格表单对话框开始 -->
    <el-dialog
      ref="formTable"
      :title="title"
      :visible.sync="topen"
      width="80%"
      v-dialogDrag
      :close-on-click-modal="false"
      v-if="topen"
    >
      <dynamic-form-table
        ref="addFormTable"
        :exsitId="exsitId"
        :geturl="geturl"
        :submiturl="addurl"
        @openTable="openTable($event)"
        @topenChanged="topenChanged"
        @clickEvent="clickEvent"
        @updateIds="setIds"
        @subBatch="subBatch"
        @loadingOpen="handleLoadingOpen"
        @loadingClose="loading = false"
        :table="table"
        :toolbar="toolbar"
        :command="command"
        :form="form"
        :formtype="formtype"
        :search="search"
        :formMulti="formMulti"
        :defaultSelect="defaultSelect"
      >
      </dynamic-form-table>
    </el-dialog>
    <!-- 一级表格表单对话框结束 -->

    <!-- 二级添加或修改对话框开始 -->
    <el-dialog
      ref="subAddForm"
      :title="subtitle"
      :visible.sync="subopen"
      width="50%"
      v-dialogDrag
      :close-on-click-modal="false"
      v-if="subopen"
    >
      <dynamic-form
        :addform="addFormData"
        :form="form"
        :rules="rules"
        :addurl="addurl"
        v-on:openChanged="openChanged"
        @loadingOpen="handleLoadingOpen"
        @loadingClose="loading = false"
      >
      </dynamic-form>
    </el-dialog>
    <!-- 二级添加或修改对话框结束 -->

    <!-- 二级表格表单对话框开始 -->
    <el-dialog
      ref="subFormTabel"
      :title="subtitle"
      :visible.sync="subtopen"
      width="80%"
      v-dialogDrag
      :close-on-click-modal="false"
      v-if="subtopen"
    >
      <dynamic-form-table
        :exsitId="exsitId"
        :geturl="geturl"
        :submiturl="addurl"
        @closeTable="closeTable($event)"
        @topenChanged="topenChanged"
        @loadingOpen="handleLoadingOpen"
        @loadingClose="loading = false"
        @clickEvent="clickEvent"
        @updateIds="setIds"
        :table="table"
        :toolbar="toolbar"
        :command="command"
        :form="form"
        :formtype="formtype"
        :search="search"
        :formMulti="formMulti"
      >
      </dynamic-form-table>
    </el-dialog>
    <!-- 导入对话框 -->
    <el-dialog
      :title="upload.title"
      :visible.sync="upload.open"
      width="400px"
      append-to-body
      v-dialogDrag
      :close-on-click-modal="false"
    >
      <el-upload
        ref="upload"
        :limit="1"
        accept=".xlsx, .xls"
        :headers="upload.headers"
        :action="upload.url"
        :disabled="upload.isUploading"
        :on-progress="handleFileUploadProgress"
        :on-success="handleFileSuccess"
        :auto-upload="false"
        drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">
          将文件拖到此处，或
          <em>点击上传</em>
        </div>
        <div class="el-upload__tip" style="color: red" slot="tip">
          提示：仅允许导入“xls”或“xlsx”格式文件！
        </div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 二级表格表单对话框开始 -->
    <portal-dialog :params="portaldialog" />
    <el-dialog
      :visible.sync="progress.open"
      v-if="progress.open"
      :before-close="
        () => {
          return false
        }
      "
      title="下载进度"
      width="30%"
    >
      <el-progress type="circle" :percentage="progress.percent"></el-progress>
    </el-dialog>
  </div>
</template>

<script>
import {
  baseRequest,
  getDataList,
  getConfigInfo,
  getData,
  delData,
  exportData,
  getTreeCommand,
  getEsData,
  updateData,
  upgrade,
  addData
} from '@/api/dynamic/dynamic'
import dynamicTable from '@/views/components/dynamicTable'
import dynamicForm from '@/views/components/dynamicForm'
import dynamicTree from '@/views/components/dynamicTree'
import dynamicFormTable from '@/views/components/dynamicFormTable'
import dynamicTreeTable from '@/views/components/dynamicTreeTable'
import { deepClone, filter2sub } from '@/utils'
import resetPwdVue from '../../system/user/profile/resetPwd.vue'
import commonFun from '@/views/mixins/commonFun'

export default {
  components: {
    dynamicForm,
    dynamicTable,
    dynamicTree,
    dynamicFormTable,
    dynamicTreeTable,
    dynamicFormItem: () => import('@/views/components/dynamicFormItem'),
    ganttChart: () => import('@/views/components/gantt/index'),
    stageGate: () => import('@/views/components/stageGate'),
    report: () => import('@/views/pms/report'),
    lifeCycle: () => import('@/views/components/lifeCycle'),
    flowChart: () => import('@/views/components/flowChart'),
    portalView: () => import('@/views/portal/index'),
    portalDialog: () => import('@/views/components/portalDialog'),
    processReview: () => import('@/views/components/processReview'),
    resizeBar: () => import('@/views/components/resizeBar'),
    superFlow: () => import('@/views/components/superFlow/index')
  },
  mixins: [commonFun],
  data() {
    return {
      isMyobject: true,
      // options: {
      //   // table 的参数
      //   stripe: true, // 是否为斑马纹 table
      //   loading: false, // 是否添加表格loading加载动画
      //   highlightCurrentRow: true, // 是否支持当前行高亮显示
      //   mutiSelect: true, // 是否支持列表项选中功能
      //   expandColumn: "name",
      // },
      // loading: false,
      updateShow: false,
      // //所选项id
      // ids: [],
      // // 所选项
      // selected: [],
      copy_ids: [],
      // 粘贴提交数据容器
      subPasteData: [],
      pasteType: 1,
      // 弹出层标题
      // title: "",
      // subtitle: "",
      // 是否显示弹出层
      // open: false,
      // topen: false,
      // subopen: false,
      // subtopen: false,
      show: true,
      flag: true,
      // total: 0,
      allData: [],
      pageTitle: '',
      url: '',
      menuUrl: '',
      params: {},
      searchFormData: [],
      toolbarData: [],
      commandData: [],
      formData: [],
      tableData: [],
      copy_table: [],
      treeMenu: [],
      treeData: [],
      columns: [], // 需要展示的列
      queryParams: {},
      configQueryParams: {},
      queryMenuParams: {},
      menuDataInfo: {},
      listQuery: {
        pageNum: 1,
        pageSize: this.$store.state.user.pageSize || 30
      },
      // operates: {
      //   // 列操作按钮
      //   width: 150,
      //   list: [],
      // },
      queryTreeParams: {},
      activeName: 'treeMenu',
      activeIndex: '0',
      dataInfo: '',
      menuData: '',
      // form: {},
      // rules: {},
      // addFormData: [],
      // addurl: "",
      copy_url: '',
      treeStr: '',
      projectid: 0,
      parentid: 0,
      type: '',
      exsitId: [],
      geturl: '',
      copy_geturl: '',
      table: '',
      toolbar: '',
      command: '',
      chart: '',
      portal: null,
      btntype: '',
      moduleName: '',
      editall: false,
      contextmenu: {
        visible: false,
        top: 0,
        left: 0
      },
      dataUrl: '',
      portaldialog: {
        open: false,
        title: 'title',
        portal: {}
      },
      taskid: 0,
      operational: '1',
      formtype: 'table',
      lifeCycleOptions: 'false',
      diff: 0,
      dif: 57,
      update: 0,
      search: 'full_search',
      self: 'true',
      photo: false,
      formMulti: 'true',
      defaultSelect: {}
    }
  },
  created() {
    let params = JSON.parse(JSON.stringify(this.$route.query))
    if (window.route) {
      params = JSON.parse(JSON.stringify(window.route.query))
      delete window.route
    }
    this.projectid = this.$route.params.Id
    if (typeof params.pageParams == 'string') {
      this.params = params = JSON.parse(
        sessionStorage.getItem(this.$route.path)
      )
      if (params && params.breadcrumb)
        this.$route.meta.breadcrumb = params.breadcrumb
    } else {
      params.breadcrumb = this.$route.meta.breadcrumb
      let temp = JSON.parse(sessionStorage.getItem(this.$route.path))
      params.currentIndex = temp ? temp.currentIndex : 0
      sessionStorage.setItem(this.$route.path, JSON.stringify(params))
      this.params = params
    }
    if (params && params.pageParams) {
      this.configQueryParams.toolbar = params.pageParams.toolbar
      this.configQueryParams.treeMenu = params.pageParams.treeMenu
      let typename = this.dataFormat('typeid', params.rowParams.typeid).trim()
      if (params.pageParams.treeMenu.indexOf('template') == -1) {
        if (typename == '门') this.configQueryParams.treeMenu = 'type_Gate'
        if (typename == '阶段') this.configQueryParams.treeMenu = 'type_Phase'
        if (typename == '任务') this.configQueryParams.treeMenu = 'type_Task'
        if (typename == '里程碑')
          this.configQueryParams.treeMenu = 'type_Milestorn'
      }
      this.url = this.getUrl(params.pageParams.url)
      this.getConfig()
    } else {
      this.msgError('缺少参数')
      return false
    }
    //this.dataInfo = this.params.rowParams;
    // setTimeout(()=>{console.log(this.tempDicts,JSON.parse(sessionStorage.getItem("tempDicts")))},5000)
  },
  updated() {
    let ele = this.$refs.dyTable || this.$refs.treeTable
    if (ele && this.update > -1) {
      this.update = -1
      this.diff = 80
      this.dif = 57
      for (let x in this.$refs) {
        if (x.indexOf('Table') == -1) {
          let h = this.$refs[x]
            ? this.$refs[x].$el
              ? this.$refs[x].$el.offsetHeight
              : this.$refs[x].offsetHeight
            : 0
          // let h=30
          this.diff += h
        }
        if (x.indexOf('topInfo') > -1) {
          this.dif = h
        }
      }
    }
  },
  watch: {
    'contextmenu.visible': {
      deep: true,
      handler: function(value) {
        if (value) {
          document.body.addEventListener('click', this.Closecontextmenu)
        } else {
          document.body.removeEventListener('click', this.Closecontextmenu)
        }
      }
    },
    total(val) {
      if (val && this.type != 'tree_table') {
        this.diff += 70
      }
    }
  },
  methods: {
    /** 获取配置信息 */
    getConfig() {
      this.loading = true
      this.getDataInfo()
      getConfigInfo(this.configQueryParams).then(response => {
        this.treeMenu = response.data.treeMenuData
        this.toolbarData = response.data.toolbarData
        // this.loading = false;
        let i = this.params.currentIndex
        this.activeIndex = i.toString()
        this.handleOpen(this.treeMenu[i], i)
      })
    },
    getMenuConfig(type) {
      this.flag = true
      // this.loading = true;
      type = type ? type : this.type
      getConfigInfo(this.queryMenuParams).then(response => {
        this.columns = response.data.tableData
        for (let index in response.data.tableData) {
          let item = response.data.tableData[index]
          if (item.propType == 'dynamic') {
            getDataList(this.getUrl(item.url)).then(res => {
              this.columns.splice(index, 1, ...res.rows)
            })
          }
        }
        // if (response.data.tableData.length > 0) {
        //   this.updateTempDicts(response.data.tableData);
        // }
        this.formData = this.formDataUpdate(response.data.showFormData)
        this.formData = this.formData.filter(
          item =>
            item.status == '1' &&
            (item.show != null && item.show != undefined && item.show != ''
              ? this.dynamicEval(this.params.rowParams, item.show)
              : true)
        )
        // if (response.data.showFormData.length > 0) {
        //   this.updateTempDicts(response.data.showFormData);
        // }
        this.operates.list = response.data.commandData
        this.toolbarData = response.data.toolbarData
        if (this.btntype === 3) {
          this.getESData()
        } else {
          this.getMenuDataInfo(type)
        }
        this.loading = false
      })
    },
    getDataInfo() {
      let type = this.$route.query.type
      if (type == undefined) type = 'pmswbs'
      // getData(type, this.projectid).then((response) => {
      //   if (response.code == 200) {
      //     this.dataInfo = response.data;
      //     this.menuDataInfo = deepClone(this.dataInfo);
      //     this.isMyobject =
      //       this.$store.state.user.roles.includes("admin") ||
      //       this.isMine(this.dataInfo.ownerid);
      //   } else {
      //     this.$message.error(response.msg);
      //   }
      // });
      getData(this.url).then(response => {
        if (response.code == 200) {
          this.dataInfo = response.data
          // console.log(this.dataInfo,this.$store.state.optionInfo.States.filter(item=>item.sort==1&&item.policyid==this.dataInfo.policyid)[0])
          this.menuDataInfo = deepClone(this.dataInfo)
          this.isMyobject =
            this.$store.state.user.roles.includes('admin') ||
            this.isMine(this.dataInfo.ownerid)
        } else {
          this.$message.error(response.msg)
        }
      })
      // if (type.indexOf("doc") > -1) {
      baseRequest(
        'pms/myWorkflow/objectTaskList',
        'get',
        { objectid: this.projectid },
        {}
      ).then(response => {
        if (response.total > 0) {
          this.taskid = response.rows[0].id
        }
      })
      // }
    },
    getMenuDataInfo(type) {
      // this.loading = true;
      if (type == 'tree') {
        getDataList(this.menuUrl).then(response => {
          this.tableData = response.rows
          this.copy_table =
            this.tableData.length > 0 ? deepClone(this.tableData) : []
          this.total = response.total
          if (this.treeStr) {
            let dataArray = response.rows
            var treeInfo = {}
            treeInfo.id = this.dataInfo.id
            treeInfo.label = this.dataInfo.name
            treeInfo.children = []
            treeInfo.url = ''
            treeInfo.pageParams = ''
            treeInfo.parentid = -1
            this.treeData = []
            this.treeData.push(treeInfo)

            getTreeCommand({ command: this.treeStr }).then(response => {
              this.commandData = response.data
              this.treeData[0].url = this.commandData[0].url
              this.treeData[0].pageParams = this.commandData[0].pageParams
              // if (this.commandData.length > 0) {
              dataArray.forEach((item, index) => {
                //     if (this.commandData[1]) {
                //       dataArray[index].url = this.commandData[1].url;
                //       dataArray[index].pageParams =
                //         this.commandData[1].pageParams;
                //     } else {
                //       dataArray[index].url = this.commandData[0].url;
                //       dataArray[index].pageParams =
                //         this.commandData[0].pageParams;
                //     }
                dataArray[index] = this.normalizer(item)
              })
              this.treeData[0].children = this.handleTree(dataArray, 'id')
              console.log(this.treeData)
              this.activeName = 'treeData'
              // }
            })
          }
          // this.loading = false;
        })
      } else if (type == 'tree_table') {
        this.dataUrl = this.menuUrl
        getDataList(this.menuUrl).then(response => {
          this.tableData = []
          if (this.self == 'true') this.tableData.push(this.dataInfo)
          this.tableData = this.tableData.concat(response.rows)
          this.copy_table =
            this.tableData.length > 0 ? deepClone(this.tableData) : []
          // this.loading = false;
        })
      } else if (type == 'form') {
        // this.menuDataInfo = deepClone(this.dataInfo);
        // this.loading = false;
      } else if (type == 'form_table') {
        this.queryParams = {
          pageNum: 1,
          pageSize: this.$store.state.user.pageSize || 30
        }
        this.dataUrl = this.menuUrl
        getDataList(this.menuUrl, this.queryParams).then(response => {
          this.tableData = response.rows
          this.copy_table =
            this.tableData.length > 0 ? deepClone(this.tableData) : []
          this.total = response.total
          // this.loading = false;
        })
      } else if (type == 'table') {
        this.queryParams = {
          pageNum: 1,
          pageSize: this.$store.state.user.pageSize || 30
        }
        this.dataUrl = this.menuUrl
        getDataList(this.menuUrl, this.queryParams).then(response => {
          this.tableData = response.rows
          // console.log(response,this.tableData)
          this.copy_table =
            this.tableData && this.tableData.length > 0
              ? deepClone(this.tableData)
              : []
          this.total = response.total
          // this.loading = false;
        })
      }
    },
    /** 从ES中获取数据 */
    getESData() {
      getEsData(this.projectid, this.moduleName, this.operation).then(
        response => {
          let EsData = response.hits.hits
          let EsTableData = []
          EsData.forEach(item => {
            EsTableData.push(item._source)
          })
          this.tableData = EsTableData
          this.copy_table =
            this.tableData.length > 0 ? deepClone(this.tableData) : []
          this.total = response.hits.total
        }
      )
    },
    /** 获取树菜单配置 */
    getTreeConfig() {
      // this.loading = true;
      getConfigInfo(this.queryTreeParams).then(response => {
        this.columns = response.data.tableData
        if (response.data.tableData.length > 0)
          this.updateTempDicts(response.data.tableData)
        this.searchFormData = response.data.searchFormData
        this.toolbarData = response.data.toolbarData
        this.operates.list = response.data.commandData
        // this.loading = false;
      })
    },
    /** 获取列表数据 */
    getList() {
      // this.loading = true;
      if (this.type == 'tree_table') {
        getDataList(this.dataUrl).then(response => {
          this.tableData = []
          if (this.self == 'true') this.tableData.push(this.dataInfo)
          this.tableData = this.tableData.concat(response.rows)
          this.copy_table =
            this.tableData.length > 0 ? deepClone(this.tableData) : []
          // this.loading = false;
        })
      } else {
        getDataList(this.dataUrl, this.queryParams).then(response => {
          this.tableData = response.rows
          this.copy_table =
            this.tableData.length > 0 ? deepClone(this.tableData) : []
          this.total = response.total
          // this.loading = false;
        })
      }
    },
    handleOpen(item, i) {
      this.loading = true
      this.update = 0
      if (this.params.currentIndex == undefined)
        this.$set(this.params, 'currentIndex', i)
      else this.params.currentIndex = i
      sessionStorage.setItem(this.$route.path, JSON.stringify(this.params))
      this.activeIndex = i.toString()
      this.formData = []
      this.columns = []
      this.treeData = []
      this.toolbarData = []
      this.tableData = []
      this.operates.list = []
      this.queryMenuParams = {}
      this.treeStr = ''
      this.chart = ''
      this.portal = null
      this.btntype = ''
      let pageParams = JSON.parse(item.pageParams.replace(/'/g, '"'))
      this.options.showSummary = pageParams.showSummary == 'true' ? true : false
      if (item.type === '3') {
        this.btntype = 3
        this.moduleName = pageParams.moduleName
          ? pageParams.moduleName
          : this.$route.query.type == 'pmsproject'
          ? '项目管理'
          : this.$route.query.type == 'doc'
          ? '文档管理'
          : ''
        this.operation = pageParams.operation ? pageParams.operation : ''
      }
      if (pageParams.chart !== '' && pageParams.chart !== undefined) {
        this.type = 'chart'
        this.chart = pageParams.chart
        if (this.chart == 'report' || this.chart == 'superFlow') {
          this.loading = false
          return
        }
        if (item.url) {
          this.menuUrl = this.getUrl(item.url)
        }
        this.table = pageParams.table
        this.toolbar = pageParams.toolbar
        this.lifeCycleOptions = pageParams.options
      }
      if (pageParams.portal !== '' && pageParams.portal !== undefined) {
        this.portal = pageParams
        this.loading = false
        return
      }
      if (pageParams.table !== '' && pageParams.table !== undefined) {
        this.queryMenuParams.table = pageParams.table
      }
      if (pageParams.toolbar !== '' && pageParams.toolbar !== undefined) {
        this.queryMenuParams.toolbar = pageParams.toolbar
      }
      if (pageParams.command !== '' && pageParams.command !== undefined) {
        this.queryMenuParams.command = pageParams.command
      }
      if (pageParams.showForm !== '' && pageParams.showForm !== undefined) {
        this.queryMenuParams.showForm = this.getUrl(
          pageParams.showForm,
          this.dataInfo
        )
      }
      if (
        pageParams.treeCommand !== '' &&
        pageParams.treeCommand !== undefined
      ) {
        this.treeStr = pageParams.treeCommand
      }
      if (item.url) {
        this.menuUrl = this.getUrl(item.url)
      }
      this.type = pageParams.type ? pageParams.type : 'table'
      this.self = pageParams.self ? pageParams.self : 'true'
      this.photo = pageParams.photo || false
      this.getMenuConfig(this.type)
    },
    handleLoadingOpen() {
      this.loading = true
      setTimeout(() => {
        this.openChanged()
        this.topenChanged()
      }, 30000)
    },
    // 数据排序
    SortList(val) {
      val.sort(function(list1, list2) {
        let list1_rank = list1.rank ? list1.rank.trim().split('.') : [0]
        let list2_rank = list2.rank ? list2.rank.trim().split('.') : [0]
        for (let i = 0; ; i++) {
          if (list1_rank[i] == undefined && list2_rank[i] == undefined)
            return true
          list1_rank[i] = list1_rank[i] == undefined ? 0 : Number(list1_rank[i])
          list2_rank[i] = list2_rank[i] == undefined ? 0 : Number(list2_rank[i])
          if (list1_rank[i] - list2_rank[i] != 0) {
            return list1_rank[i] - list2_rank[i]
          }
        }
      })
    },
    // // 按钮点击事件操作
    // clickEvent(obj) {
    //   if (obj.name == "全编辑") {
    //     this.editall = !this.editall;
    //     if (obj.pageParams) {
    //       var pageParams = JSON.parse(obj.pageParams.replace(/'/g, '"'));
    //       this.addurl = pageParams.submiturl;
    //     }
    //     if (this.$refs.treeTable) {
    //       this.$refs.treeTable.editall = this.editall;
    //       // this.$refs.treeTable.getEditForm(obj.url)
    //     } else {
    //       this.$refs.dyTable.editall = this.editall;
    //       // this.$refs.dytable.getEditForm(obj.url)
    //     }
    //     return;
    //   }
    //   if (obj.type === "2") {
    //     if (obj.url.indexOf("http") > -1) {
    //       window.open(obj.url);
    //       return false;
    //     }
    //     if (this.ids.length !== 1 && obj.location !== "2") {
    //       this.msgError("不能对没有选中或者选中多个的数据进行此项操作！");
    //       return false;
    //     }
    //     if (obj.url) {
    //       let pageParams = JSON.parse(obj.pageParams.replace(/'/g, '"'));
    //       let params = {};
    //       var pid = "";
    //       if (obj.location !== "2") pid = this.ids[0];
    //       else pid = this.projectid;
    //       pageParams.url = obj.url;
    //       pageParams.title = obj.name;
    //       pageParams.projectid = this.projectid;
    //       params.pageParams = pageParams;
    //       this.$router.push({
    //         path: "/dynamic/" + pageParams.route + "/" + pid,
    //         query: params,
    //       });
    //     }
    //   } else {
    //     this.table = "";
    //     this.toolbar = "";
    //     this.title = "";
    //     this.command = "";
    //     let pageParams = JSON.parse(obj.pageParams.replace(/'/g, '"'));
    //     // if (pageParams.condition) {
    //     //   if (!this.jugeCondition(pageParams.condition).flag) {
    //     //     return false;
    //     //   }
    //     // }
    //     if (pageParams.multi != undefined) this.formMulti = pageParams.multi;
    //     this.loading = true;
    //     if (pageParams.handle == "handleDelete") {
    //       this.handleDelete(obj.url, obj.description);
    //     } else if (pageParams.handle == "handleExport") {
    //       this.handleExport(obj.url);
    //     } else if (pageParams.handle == "handleAdd") {
    //       if (pageParams.type && pageParams.type.indexOf("table") > -1) {
    //         this.handleAddExited(obj);
    //       } else {
    //         if (obj.sub)
    //           this.handleAdd(
    //             obj.url,
    //             pageParams.addForm,
    //             obj.description,
    //             true
    //           );
    //         else this.handleAdd(obj.url, pageParams.addForm, obj.description);
    //       }
    //     } else if (pageParams.handle == "handleAddChild") {
    //       if (obj.sub)
    //         this.handleAddChild(
    //           obj.url,
    //           pageParams.addForm,
    //           obj.description,
    //           true
    //         );
    //       else
    //         this.handleAddChild(obj.url, pageParams.addForm, obj.description);
    //     } else if (pageParams.handle == "handleAddAssign") {
    //       this.handleAddAssign(obj);
    //     } else if (pageParams.handle == "handlePortal") {
    //       this.handlePortal(obj);
    //     } else if (pageParams.handle == "handleConfirm") {
    //       this.handleConfirm(
    //         obj.url,
    //         pageParams.method,
    //         obj.description,
    //         pageParams.condition
    //       );
    //     } else if (pageParams.handle == "handleUpgrade") {
    //       this.handleUpgrade(obj.url);
    //     } else if (pageParams.handle == "handleUpdate") {
    //       if (obj.sub)
    //         this.handleUpdate(
    //           obj.url,
    //           pageParams.addForm,
    //           obj.description,
    //           true
    //         );
    //       else this.handleUpdate(obj.url, pageParams.addForm, obj.description);
    //     } else if (pageParams.handle == "handleBatch") {
    //       this.handleBatch(obj, pageParams.addForm, pageParams.table);
    //     } else if (pageParams.handle == "handleCopy") {
    //       // 新增版本
    //       this.$confirm("确认新增版本?", "提示", {
    //         confirmButtonText: "确定",
    //         cancelButtonText: "取消",
    //         type: "warning",
    //       })
    //         .then(() => {
    //           getDataList(obj.url, { id: this.$route.params.Id }).then(
    //             (response) => {
    //               if (response.code == 200) {
    //                 this.msgSuccess(response.msg);
    //                 let i = Number(this.activeIndex);
    //                 this.handleOpen(this.treeMenu[i], i);
    //                 return true;
    //               } else {
    //                 this.msgError(response.msg);
    //                 return true;
    //               }
    //             }
    //           );
    //         })
    //         .catch(() => {
    //           this.msgInfo("已取消");
    //         });
    //     } else if (pageParams.handle == "handleOpen") {
    //       let i = this.params.currentIndex;
    //       this.handleOpen(obj, i);
    //     } else if (pageParams.handle == "handleTable") {
    //       let i = this.params.currentIndex;
    //       this.openTable({
    //         url: obj.url,
    //         str: pageParams,
    //         id: this.ids,
    //         title: obj.description,
    //       });
    //     }
    //     this.loading = false;
    //   }
    // },
    // handleConfirm(url, method, title, condition) {
    //   let jugement = this.jugeCondition(condition, url, title);
    //   if (jugement.flag) {
    //     this.$confirm(jugement.info, "提示", {
    //       confirmButtonText: "确定",
    //       cancelButtonText: "取消",
    //       type: "warning",
    //     })
    //       .then(() => {
    //         baseRequest(jugement.route, method, {}, {}).then((response) => {
    //           if (response.code == 200) {
    //             this.msgSuccess(response.msg);
    //             this.refreshCurrent();
    //             return true;
    //           } else {
    //             this.msgError(response.msg);
    //             return true;
    //           }
    //         });
    //       })
    //       .catch(() => {
    //         this.msgInfo("已取消");
    //       });
    //   }
    // },
    // handlePortal(obj) {
    //   this.portaldialog.open = true;
    //   this.portaldialog.title = obj.description;
    //   this.portaldialog.portal = { portal: obj.pageParams.portal };
    // },
    startWorkflow() {
      this.$confirm('确定启动文档流程？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          baseRequest(
            '/pms/workflow/documentStartUpWorkflowList',
            'get',
            { workflowid: this.projectid },
            {}
          ).then(response => {
            if (response.code == 200) {
              this.msgSuccess(response.msg)
              this.refreshCurrent()
              return true
            } else {
              this.msgError(response.msg)
              return true
            }
          })
        })
        .catch(() => {
          this.msgInfo('已取消')
        })
    },
    recallWorkflow(mark = 'cancel') {
      this.$confirm(
        `确定${mark == 'cancel' ? '取消' : '回收'}文档流程？`,
        '提示',
        {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }
      )
        .then(() => {
          let url =
            mark == 'cancel'
              ? '/pms/workflow/objectWorkflowCancel/' + this.projectid
              : '/pms/workflow/objectWorkflowRecovery/' + this.projectid
          baseRequest(url, 'get', {}, {}).then(response => {
            if (response.code == 200) {
              this.msgSuccess(response.msg)
              this.refreshCurrent()
              return true
            } else {
              this.msgError(response.msg)
              return true
            }
          })
        })
        .catch(() => {
          this.msgInfo('已取消')
        })
    },
    // 全编辑预加载
    getEditForm(str) {
      if (
        (this.$refs.treeTable &&
          typeof this.$refs.treeTable.addFormData == '{}') ||
        (this.$refs.dyTable && typeof this.$refs.dyTable.addFormData == '{}') ||
        (!this.$refs.treeTable && !this.$refs.dyTable)
      ) {
        this.getFormData(str)
        setTimeout(() => {
          if (this.$refs.treeTable) {
            for (let current of this.addFormData) {
              this.$refs.treeTable.addFormData[current.prop] = current
            }
          } else {
            for (let current of this.addFormData) {
              this.$refs.dyTable.addFormData[current.prop] = current
            }
          }
        }, 1000)
      }
      return true
    },
    // 保存全编辑
    subEditAll() {
      let keys = this.columns
        .filter(item => {
          return !(item.fullEdit == 'false' || item.fullEdit == null)
        })
        .map(item => item.prop)
      // this.SortList(this.copy_table);
      let subData = filter2sub(keys, this.tableData, this.copy_table)
      // console.log(subData);return
      if (subData.length == 0) {
        this.msgInfo('未修改任何数据')
        this.cancelEditAll()
      } else {
        updateData(this.getUrl(this.addurl), subData)
          .then(response => {
            if (response.code == 200) {
              this.getList()
              this.flag = true
              this.msgSuccess(response.msg)
            } else {
              this.tableData =
                this.copy_table.length > 0 ? deepClone(this.copy_table) : []
              this.flag = true
              this.msgError(response.msg)
            }
          })
          .catch(() => {
            this.tableData =
              this.copy_table.length > 0 ? deepClone(this.copy_table) : []
            this.flag = true
          })
      }
      this.editall = !this.editall
      if (this.$refs.treeTable) this.$refs.treeTable.editall = this.editall
      else this.$refs.dyTable.editall = this.editall
    },
    //取消全编辑
    cancelEditAll() {
      this.editall = !this.editall
      if (this.$refs.treeTable) this.$refs.treeTable.editall = this.editall
      else this.$refs.dyTable.editall = this.editall
      this.tableData =
        this.copy_table.length > 0 ? deepClone(this.copy_table) : []
      this.flag = true
    },
    // /** 新增按钮操作 */
    // handleAdd(url, str, title, sub = false) {
    //   this.addurl = this.getUrl(url, this.$data);
    //   this.getFormData(str, true);
    //   if (!sub) {
    //     this.form = {
    //       projectid: this.dataInfo.projectid
    //         ? this.dataInfo.projectid
    //         : this.dataInfo.id,
    //       parentid: this.parentid,
    //     };
    //     if (this.ids.length > 0) this.form["toid"] = Number(this.ids[0]);
    //     if (this.dataInfo.projectid) this.form["pmsid"] = this.projectid;
    //     this.open = true;
    //     this.title = title;
    //   } else {
    //     this.form = {
    //       projectid: this.dataInfo.projectid
    //         ? this.dataInfo.projectid
    //         : this.dataInfo.id,
    //       parentid: this.parentid,
    //       toid: this.form.toid,
    //       pmsid: this.form.pmsid,
    //     };
    //     if (this.ids.length > 0) this.form["fromid"] = Number(this.ids[0]);
    //     if (this.dataInfo.projectid) this.form["pmsid"] = this.projectid;
    //     this.subopen = true;
    //     this.subtitle = title;
    //   }
    //   for (let item of this.addFormData) {
    //     if (item.status == "1") {
    //       this.$set(this.form, item.prop, item.defaultValue);
    //     }
    //   }
    // },
    // /**  添加已存在*/
    // handleAddExited(obj) {
    //   let pageParams = eval("(" + obj.pageParams + ")");
    //   this.addurl = obj.url;
    //   this.table = pageParams.table;
    //   this.toolbar = pageParams.toolbar;
    //   this.command = pageParams.command;
    //   this.formtype = pageParams.type;
    //   if (pageParams.search != undefined) this.search = pageParams.search;
    //   this.geturl = this.getUrl(pageParams.getUrl);
    //   if (obj.sub) {
    //     this.form = {
    //       projectid: this.projectid,
    //       parentid: this.parentid,
    //       toid: this.form.toid,
    //       formid: this.ids[0],
    //       pmsid: this.form.pmsid,
    //     };
    //     this.subtopen = true;
    //     this.subtitle = obj.description;
    //   } else {
    //     this.copy_geturl = this.geturl;
    //     if (this.ids.length > 0)
    //       this.form = {
    //         projectid: this.dataInfo.projectid
    //           ? this.dataInfo.projectid
    //           : this.dataInfo.id,
    //         parentid: this.parentid,
    //         toid: this.ids[0],
    //       };
    //     else
    //       this.form = {
    //         projectid: this.dataInfo.projectid
    //           ? this.dataInfo.projectid
    //           : this.dataInfo.id,
    //         parentid: this.parentid,
    //       };
    //     if (this.dataInfo.projectid) this.form["pmsid"] = this.projectid;
    //     this.title = obj.description;
    //     this.topen = true;
    //   }
    // },
    // /** 添加已存在*/
    // handleAddAssign(obj) {
    //   if (this.ids.length == 0) {
    //     this.msgError("不能对没有选中进行此项操作！");
    //     return false;
    //   }
    //   if (this.level === 0) {
    //     this.ids[0] = 0;
    //   }
    //   let pageParams = eval("(" + obj.pageParams + ")");
    //   this.addurl = obj.url;
    //   this.table = pageParams.table;
    //   this.toolbar = pageParams.toolbar;
    //   this.command = pageParams.command;
    //   this.formtype = pageParams.type;
    //   if (pageParams.defaultSelect) {
    //     let arr = pageParams.defaultSelect.split("-");
    //     this.defaultSelect[arr[0]] = this.selected[0][arr[1]].split(",");
    //   } else {
    //     this.defaultSelect = {};
    //   }
    //   if (pageParams.search != undefined) this.search = pageParams.search;
    //   // if (pageParams.getUrl.indexOf("{") != -1) {
    //   //   var url = pageParams.getUrl.substring(
    //   //     0,
    //   //     pageParams.getUrl.indexOf("{")
    //   //   );
    //   //   var substr = pageParams.getUrl.substring(
    //   //     pageParams.getUrl.indexOf("{") + 1,
    //   //     pageParams.getUrl.indexOf("}")
    //   //   );
    //   //   this.geturl = url + this.dataInfo[substr];
    //   // } else {
    //   //   this.geturl = pageParams.getUrl;
    //   // }
    //   // console.log(pageParams.getUrl)
    //   this.geturl = this.getUrl(pageParams.getUrl);
    //   if (obj.sub) {
    //     this.form = {
    //       toid: this.form.toid,
    //       fromid: this.ids,
    //       projectid: this.projectid,
    //     };
    //     this.subtitle = obj.description;
    //     this.subtopen = true;
    //   } else {
    //     this.copy_geturl = this.geturl;
    //     this.form = {
    //       pmsid: this.ids.join(","),
    //       toid: this.ids.join(","),
    //       projectid: this.projectid,
    //     };
    //     this.title = obj.description;
    //     this.topen = true;
    //   }
    // },
    // /** 增加下层按钮操作 */
    // handleAddChild(url, str, title, sub = false) {
    //   this.addurl = url;
    //   if (this.ids.length !== 1) {
    //     this.msgError("不能对没有选中或者选中多个的数据进行此项操作！");
    //     return false;
    //   }
    //   if (this.level === 0) {
    //     this.form = {
    //       projectid: this.projectid,
    //       parentid: 0,
    //       level: this.level,
    //     };
    //   } else {
    //     this.form = {
    //       projectid: this.projectid,
    //       parentid: this.ids[0],
    //       level: this.level,
    //     };
    //   }
    //   this.getFormData(str, true);
    //   if (sub) {
    //     this.subtitle = title;
    //     this.subopen = true;
    //   } else {
    //     this.open = true;
    //     this.title = title;
    //   }
    // },
    // /** 修改按钮操作 */
    // handleUpdate(url, str, title, sub = false) {
    //   if (this.ids.length != 1) {
    //     this.msgInfo("请选择一条数据");
    //     return false;
    //   }
    //   this.addurl = url;
    //   this.getFormData(str);
    //   this.form = deepClone(this.selected[0]);
    //   // this.open = true;
    //   // this.title = val.title ? val.title : "编辑";
    //   if (this.sub) {
    //     this.subopen = true;
    //     this.subtitle = title;
    //   } else {
    //     this.open = true;
    //     this.title = title;
    //   }
    // },
    // /** 删除按钮操作 */
    // handleDelete(url, title) {
    //   const ids = this.ids;
    //   this.$confirm(
    //     `是否确认${title} ${
    //       this.selected[0].name ||
    //       this.selected[0].title ||
    //       this.selected[0].fileName ||
    //       this.selected[0].folderName ||
    //       ""
    //     } ${this.ids.length > 1 ? "等" : ""}?`,
    //     "警告",
    //     {
    //       confirmButtonText: "确定",
    //       cancelButtonText: "取消",
    //       type: "warning",
    //     }
    //   )
    //     .then(function () {
    //       return delData(url, ids);
    //     })
    //     .then(() => {
    //       this.refreshCurrent();
    //       this.msgSuccess("删除成功");
    //     })
    //     .catch(function () {});
    // },
    // /** 升级降级操作 */
    // handleUpgrade(url) {
    //   const ids = this.ids;
    //   if (this.JugeSeletions().sameState) {
    //     this.$confirm(
    //       `是否确认升级 ${
    //         this.selected[0].name ||
    //         this.selected[0].title ||
    //         this.selected[0].fileName ||
    //         this.selected[0].folderName ||
    //         ""
    //       } ${this.ids.length > 1 ? "等" : ""}的数据项?`,
    //       "警告",
    //       {
    //         confirmButtonText: "确定",
    //         cancelButtonText: "取消",
    //         type: "warning",
    //       }
    //     )
    //       .then(function () {
    //         return upgrade(url, ids);
    //       })
    //       .then(() => {
    //         this.refreshCurrent();
    //         this.msgSuccess("提升成功");
    //       })
    //       .catch(function () {});
    //   } else {
    //     this.msgError("请选择同一状态的数据！");
    //   }
    // },
    // /** 降级操作 */
    // handleDemotion(url) {
    //   const ids = this.ids;
    //   if (this.JugeSeletions().sameState) {
    //     this.$confirm(
    //       `是否确认升级 ${
    //         this.selected[0].name ||
    //         this.selected[0].title ||
    //         this.selected[0].fileName ||
    //         this.selected[0].folderName ||
    //         ""
    //       } ${this.ids.length > 1 ? "等" : ""}的数据项?`,
    //       "警告",
    //       {
    //         confirmButtonText: "确定",
    //         cancelButtonText: "取消",
    //         type: "warning",
    //       }
    //     )
    //       .then(function () {
    //         return upgrade(url, ids);
    //       })
    //       .then(() => {
    //         this.refreshCurrent();
    //         this.msgSuccess("降级成功");
    //       })
    //       .catch(function () {});
    //   } else {
    //     this.msgError("请选择同一状态的数据！");
    //   }
    // },
    // /** 导出按钮操作 */
    // handleExport(url) {
    //   const queryParams = this.queryParams;
    //   this.$confirm("是否确认导出所有数据项?", "警告", {
    //     confirmButtonText: "确定",
    //     cancelButtonText: "取消",
    //     type: "warning",
    //   })
    //     .then(function () {
    //       return exportData(url, queryParams);
    //     })
    //     .then((response) => {
    //       this.download(response.msg);
    //     })
    //     .catch(function () {});
    // },
    // openChanged(val) {
    //   this.loading = false;
    //   if (this.subopen) {
    //     this.subopen = false;
    //     if (this.addurl.indexOf("Restrain") > -1) this.topenChanged(true);
    //     if (this.addurl.indexOf("pmsbatch") > -1) this.refreshCurrent();
    //     if (val) {
    //       this.$refs.addFormTable.getList();
    //     }
    //   } else {
    //     this.open = false;
    //     if (val) {
    //       this.ids = [];
    //       this.refreshCurrent();
    //     }
    //   }
    // },
    // topenChanged(val) {
    //   this.loading = false;
    //   if (this.subtopen) {
    //     this.subtopen = false;
    //     this.geturl = this.copy_geturl;
    //     this.$refs.addFormTable.getList(this.copy_geturl);
    //   } else {
    //     this.topen = false;
    //     if (val) {
    //       this.ids = [];
    //       this.getConfig(this.type);
    //     }
    //   }
    // },
    // editChanged(val) {
    //   this.addurl = val.url;
    //   this.form = {};
    //   if (val.url) {
    //     if (val.url.indexOf("/UpdateFile") == -1) {
    //       if (typeof val.id != "number") {
    //         this.form = val.id;
    //         this.open = true;
    //         this.title = val.title ? val.title : "编辑";
    //         this.getFormData(val.str);
    //       } else {
    //         getData(val.url, val.id).then((response) => {
    //           this.form = response.data;
    //           this.open = true;
    //           this.title = val.title ? val.title : "编辑";
    //           this.getFormData(val.str);
    //         });
    //       }
    //     } else {
    //       this.form = {
    //         id: val.id,
    //         fileList: [],
    //         projectid: this.projectid,
    //         parentid: this.parentid,
    //       };
    //       this.open = true;
    //       this.title = val.title ? val.title : "编辑";
    //       this.getFormData(val.str);
    //     }
    //   } else {
    //     this.open = true;
    //     this.title = val.title ? val.title : "编辑";
    //     this.getFormData(val.str);
    //   }
    // },
    openTable(val) {
      let pageParams = val.str
      this.copy_url = this.addurl
      this.addurl = val.url
      this.table = pageParams.table
      this.toolbar = pageParams.toolbar
      this.command = pageParams.command
      this.search = pageParams.search
      if (pageParams.getUrl.indexOf('{') != -1) {
        var url = pageParams.getUrl.substring(0, pageParams.getUrl.indexOf('{'))
        this.geturl = url + val.id
      } else {
        this.geturl = pageParams.getUrl
      }
      this.form = {
        toid: this.ids[0],
        projectid: this.projectid,
        pmsid: val.id
      }
      if (val.sub) {
        this.subtopen = true
        this.form['rowid'] = val.id
        this.form['type'] = pageParams.type
        this.subtitle = val.title ? val.title : ''
      } else {
        this.copy_geturl = this.geturl
        this.topen = true
        this.title = val.title ? val.title : ''
      }
    },
    closeTable(val) {
      let list = this.$refs.addFormTable.$refs.treeTable.GetList(
        this.form['rowid']
      )
      list.params[this.form.type] =
        val.length > 0 ? val.map(item => item.id).join(',') : ''
      list[this.form.type] =
        val.length > 0 ? val.map(item => item.userName).join(',') : ''
      this.$refs.addFormTable.submitData[list.id] = {
        id: list.id,
        params: list.params,
        projectid: this.projectid
      }
      this.addurl = this.copy_url
      this.subtopen = false
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.selected = selection
      this.exsitId = this.ids
      if (selection.length > 0) {
        if (selection[0].hasOwnProperty('level')) {
          this.level = selection[0].level
        }
      }
    },
    // 节点单击事件
    handleNodeClick(data) {
      if (typeof data != 'object') {
        this.$refs.dynamicTree.handleNodeClick(data)
        return
      }
      if (data.parentid === -1) {
        this.parentid = 0
      } else {
        this.parentid = data.id
      }

      if (data.parentid == -1) {
        data.pageParams = this.commandData[0].pageParams
        data.url = this.commandData[0].url
      } else if (data.children && data.children.length > 0) {
        let commandData = this.commandData[1] || this.commandData[0]
        data.pageParams = commandData.pageParams
        data.url = commandData.url
      } else {
        let commandData =
          this.commandData[2] || this.commandData[1] || this.commandData[0]
        data.pageParams = commandData.pageParams
        data.url = commandData.url
      }
      var pageParams = JSON.parse(data.pageParams.replace(/'/g, '"'))
      this.type = pageParams.type || 'table'
      this.queryTreeParams = {}
      this.portal = false
      if (pageParams.portal !== '' && pageParams.portal !== undefined) {
        this.portal = pageParams
        return
      }
      if (pageParams.command !== '' && pageParams.command !== undefined) {
        this.queryTreeParams.command = pageParams.command
      }
      if (pageParams.table !== '' && pageParams.table !== undefined) {
        this.queryTreeParams.table = pageParams.table
      }
      if (pageParams.form !== '' && pageParams.form !== undefined) {
        this.queryTreeParams.form = pageParams.form
      }
      if (pageParams.toolbar !== '' && pageParams.toolbar !== undefined) {
        this.queryTreeParams.toolbar = pageParams.toolbar
      }
      this.getTreeConfig()
      var url = data.url
      this.queryParams = {
        pageNum: 1,
        pageSize: this.$store.state.user.pageSize || 30
      }
      if (this.type != 'table') {
        this.queryParams = {}
      }
      // if (url.indexOf("{") != -1) {
      //   var substr1 = url.substring(url.indexOf("?") + 1, url.indexOf("="));
      //   var substr2 = url.substring(url.indexOf("{") + 1, url.indexOf("}"));
      //   url = url.substring(0, url.indexOf("?"));
      //   this.queryParams[substr1] = data[substr2];
      // }
      this.dataUrl = this.getUrl(url, this.$data)
      this.getList()
      this.flag = true
    },
    // /** 转换数据结构 */
    // normalizer(node) {
    //   return {
    //     id: node.id,
    //     label: node.folderName,
    //     parentid: node.parentid,
    //     url: node.url,
    //     pageParams: node.pageParams,
    //   };
    // },
    //保存
    handleSaveForm() {
      updateData(
        '/' + (this.$route.query.edit || this.$route.query.type),
        this.menuDataInfo
      )
        .then(response => {
          if (response.code == 200) {
            this.msgSuccess(response.msg)
            this.dataInfo = deepClone(this.menuDataInfo)
            this.params.rowParams = deepClone(this.menuDataInfo)
            sessionStorage.setItem(
              this.$route.path,
              JSON.stringify(this.params)
            )
            this.updateShow = false
          } else {
            this.msgError(response.msg)
            this.menuDataInfo = deepClone(this.dataInfo)
            this.updateShow = false
          }
        })
        .catch(() => {
          this.menuDataInfo = deepClone(this.dataInfo)
          this.updateShow = false
        })
    },
    handleCancelForm() {
      this.menuDataInfo = deepClone(this.dataInfo)
      this.updateShow = false
    },
    SetFlag() {
      this.flag = false
    },
    setIds(val) {
      this.ids = val
    },
    // 打开右键菜单
    Opencontextmenu(e) {
      this.contextmenu.left =
        e.clientX - 100 < 0
          ? 0
          : document.body.clientWidth - e.clientX < 100
          ? document.body.clientWidth - 200
          : e.clientX - 100
      this.contextmenu.top =
        document.body.clientHeight - e.clientY < 250
          ? e.clientY - 170
          : e.clientY - 80
      this.contextmenu.visible = true
    },
    Closecontextmenu() {
      this.contextmenu.visible = false
    },
    // 任务复制||剪切
    /*
      type:类型 copy 复制 cut 剪切
      */
    copy(type = 'copy') {
      if (this.ids == 0) {
        this.msgInfo('未选择任何数据')
      } else {
        this.copy_ids = []
        this.pasteType = type == 'copy' ? 1 : 2
        for (let id of this.ids) {
          let tabledata = deepClone(this.tableData)
          let list = this.$refs.treeTable.GetList(id)
          list.checked = false
          list[type] = true
          this.copy_ids = this.copy_ids.concat(
            tabledata.splice(list.rowIndex, list.allChildren.length + 1)
          )
          this.$refs.treeTable.HandleCheckedChange(list)
        }
      }
    },
    // 任务粘贴
    /*
        level:级别 0 同级  1 子级
      */
    paste(level = 1) {
      if (this.ids.length != 1) {
        this.msgInfo('请选择一项任务')
        return false
      } else {
        let current = this.$refs.treeTable.GetList(this.ids[0])
        for (let index = 0; index < this.copy_ids.length; index++) {
          let list = this.copy_ids[index]
          list.paste = true
          list.id = list.id + this.tableData.length
          let oldLevel = Number(list.level)
          let oldRank = list.rank.trim()
          list.level = current.level + level
          // 粘贴为同级
          if (level == 0) {
            list.parentid = Number(current.parentid)
            let parent = this.$refs.treeTable.GetList(current.parentid)
            list.rank = parent.rank
              ? parent.rank.trim() +
                '.' +
                String(Number(parent.children.length) + Number(index) + 1)
              : String(Number(parent.children.length) + Number(index) + 1)
          }
          // 粘贴为子级
          else {
            list.parentid = Number(current.id)
            list.rank =
              current.rank.trim() +
              '.' +
              String(Number(current.children.length) + Number(index) + 1)
          }
          this.subPasteData.push({
            fromid: String(list.id - this.tableData.length),
            toid: current.id,
            type: this.pasteType,
            grade: level == 1 ? 2 : 1
          })
          if (list.allChildren.length > 0) {
            let parentid = [list.id]
            index++
            for (let i in list.allChildren) {
              let row = this.copy_ids[Number(index) + Number(i)]
              row.paste = true
              row.id = row.id + this.tableData.length
              parentid[row.level - oldLevel] = row.id
              row.parentid = parentid[row.level - oldLevel - 1]
              row.level = list.level + row.level - oldLevel
              row.rank = row.rank.replace(oldRank, list.rank)
            }
            index += list.allChildren.length - 1
          }
          this.$refs.treeTable.defaultExpand.push(current.id)
          this.ids = []
          sessionStorage.setItem(
            'expand' + this.$route.query.type + this.$route.params.Id,
            JSON.stringify(this.$refs.treeTable.defaultExpand)
          )
        }
        this.tableData.splice(
          Number(current.rowIndex) + 1 + Number(current.allChildren.length),
          0,
          ...this.copy_ids
        )
        this.flag = true
        this.$refs.treeTable.toggle = !this.$refs.treeTable.toggle
      }
    },
    // 保存粘贴数据
    submit() {
      // console.log(this.subPasteData);return
      addData('/pmswbs/copywbs', this.subPasteData)
        .then(response => {
          if (response.code == 200) {
            this.msgSuccess(response.msg)
            this.getConfig()
          } else {
            this.msgError(response.msg)
            this.tableData = deepClone(this.copy_table)
          }
        })
        .catch(() => {
          this.tableData = deepClone(this.copy_table)
        })
      this.copy_ids = []
      this.subPasteData = []
      this.flag = true
    },
    reset() {
      this.tableData =
        this.copy_table.length > 0 ? deepClone(this.copy_table) : []
      this.copy_ids = []
      this.subPasteData = []
      this.flag = true
    },
    // 批量编辑
    handleBatch(obj, addForm, table) {
      this.title = '批量编辑'
      if (this.ids.length == 0) {
        this.msgInfo('请选择修改数据行')
      } else {
        if (
          this.$route.query.type == '/pmsproject' &&
          this.ids.indexOf(Number(this.projectid)) > -1
        ) {
          this.msgInfo('批量编辑不支持项目的修改')
        } else {
          this.getFormData(addForm)
          this.table = 'form_col'
          this.addurl = obj.url
          this.geturl = table
          this.topen = true
        }
      }
    },
    subBatch(addform) {
      this.subtitle = '批量编辑'
      this.topen = false
      for (let i in addform) {
        let col = addform[i]
        let current = this.addFormData.filter(item => {
          return item.prop == col.prop
        })
        if (current.length > 0) addform[i] = current[0]
        else {
          addform[i].editable = true
        }
      }
      this.form['ids'] = this.ids.join(',')
      this.addFormData = addform
      this.subopen = true
    }
    // //获取表单数据
    // getFormData(str, flag) {
    //   // let formData = {};
    //   getAddForm({ addForm: str }).then((response) => {
    //     // formData = response.data;
    //     // formData.forEach((item, index) => {
    //     //   if (
    //     //     item.componentType === "el-select" ||
    //     //     item.componentType === "el-selects" ||
    //     //     item.componentType === "el-radio" ||
    //     //     item.componentType === "el-checkbox-group"
    //     //   ) {
    //     //     if (
    //     //       item.prop === "policyid" ||
    //     //       item.prop === "stateid" ||
    //     //       item.prop === "ownerid"
    //     //     ) {
    //     //       formData[index].optionValue = optionData[item.optionValue];
    //     //     } else {
    //     //       if (
    //     //         this.tempDicts[item.prop] &&
    //     //         this.tempDicts[item.prop].length > 0
    //     //       ) {
    //     //         formData[index].optionValue = this.selectNormalizer(
    //     //           deepClone(this.tempDicts[item.prop])
    //     //         );
    //     //       } else {
    //     //         if (item.optionValue){
    //     //             if(item.optionValue.indexOf("url") > -1) {
    //     //             let url = this.getUrl(item.optionValue.split(":")[1]);
    //     //             getDataList(url).then((response) => {
    //     //               if (response.code == 200) {
    //     //                 this.tempDicts[item.prop] = deepClone(response.rows)
    //     //                 // sessionStorage.setItem('tempDicts',JSON.stringify(this.tempDicts))
    //     //                 formData[index].optionValue = response.rows;
    //     //                 if(response.rows&&response.rows.length==1){
    //     //                   // console.log(response.rows)
    //     //                   this.form[item.prop]=response.rows[0].id
    //     //                 }
    //     //               }
    //     //             });
    //     //             } else {
    //     //               this.getDicts(item.optionValue).then((response) => {
    //     //                 this.tempDicts[item.prop] = deepClone(response.data);
    //     //                 // sessionStorage.setItem('tempDicts',JSON.stringify(this.tempDicts))
    //     //                 formData[index].optionValue = this.selectNormalizer(
    //     //                   response.data
    //     //                 );
    //     //               });
    //     //             }
    //     //         }else if(item.show&&this.form.id){
    //     //           getDataList(this.getUrl(item.show,this.form)).then(
    //     //             (response) => {
    //     //               if (response.code == 200) {
    //     //                 item.optionValue = response.rows;
    //     //               }
    //     //             }
    //     //           );
    //     //         }
    //     //       }
    //     //     }
    //     //   }
    //     //   if (item.componentType === "el-cascader") {
    //     //     let optionarr = item.optionValue.split("?");
    //     //     if (optionarr.length > 1) {
    //     //       this.optionNormalizer(optionData[optionarr[0]]);
    //     //       let typearr = [];
    //     //       optionData[optionarr[0]].forEach((titem) => {
    //     //         if (titem.value === parseInt(optionarr[1])) {
    //     //           typearr.push(titem);
    //     //           formData[index].optionValue = typearr;
    //     //         }
    //     //       });
    //     //     } else {
    //     //       formData[index].optionValue = this.optionNormalizer(
    //     //         optionData[item.optionValue]
    //     //       );
    //     //     }
    //     //   }
    //     // });
    //     this.addFormData = this.formDataUpdate(response.data);
    //     if (flag) {
    //       for (let item of this.addFormData) {
    //         if (this.form[item.prop] == undefined && item.defaultValue) {
    //           this.$set(this.form, item.prop, this.dynamicEval(item.defaultValue,this.dataInfo));
    //         }
    //       }
    //     }
    //   });
    // },
    // formDataUpdate(data) {
    //   let optionData = JSON.parse(sessionStorage.getItem("optionsData"));
    //   let formData = data;
    //   formData.forEach((item, index) => {
    //     if (
    //       item.componentType === "el-select" ||
    //       item.componentType === "el-selects" ||
    //       item.componentType === "el-radio" ||
    //       item.componentType === "el-checkbox-group"
    //     ) {
    //       if (
    //         item.prop === "policyid" ||
    //         item.prop === "stateid" ||
    //         item.prop === "ownerid"
    //       ) {
    //         formData[index].optionValue = optionData[item.optionValue];
    //       } else {
    //         if (
    //           this.tempDicts[item.prop] &&
    //           this.tempDicts[item.prop].length > 0
    //         ) {
    //           formData[index].optionValue = this.selectNormalizer(
    //             deepClone(this.tempDicts[item.prop])
    //           );
    //           let tempDicts = JSON.parse(sessionStorage.getItem("tempDicts"));
    //           tempDicts[item.prop] = deepClone(this.tempDicts[item.prop]);
    //           sessionStorage.setItem("tempDicts", JSON.stringify(tempDicts));
    //         } else {
    //           if (item.optionValue) {
    //             if (item.optionValue.indexOf("url") > -1) {
    //               let url = this.getUrl(item.optionValue.split(":")[1]);
    //               let appendid = this.$route.params.Id;
    //               if (item.optionValue.indexOf("{") > -1) {
    //                 if (this.$route.query.type.indexOf("pmswbs") > -1) {
    //                   appendid = this.dataInfo.projectid;
    //                 }
    //                 if (
    //                   this.tempDicts[item.prop + "-" + appendid] == undefined
    //                 ) {
    //                   getDataList(url).then((response) => {
    //                     this.tempDicts[item.prop + "-" + appendid] =
    //                       response.rows;
    //                     let tempDicts = JSON.parse(
    //                       sessionStorage.getItem("tempDicts")
    //                     );
    //                     tempDicts[item.prop + "-" + appendid] = deepClone(
    //                       response.rows
    //                     );
    //                     sessionStorage.setItem(
    //                       "tempDicts",
    //                       JSON.stringify(tempDicts)
    //                     );
    //                   });
    //                 } else {
    //                   let tempDicts = JSON.parse(
    //                     sessionStorage.getItem("tempDicts")
    //                   );
    //                   tempDicts[item.prop + "-" + appendid] = deepClone(
    //                     this.tempDicts[item.prop + "-" + appendid]
    //                   );
    //                   sessionStorage.setItem(
    //                     "tempDicts",
    //                     JSON.stringify(tempDicts)
    //                   );
    //                 }
    //               } else if (this.tempDicts[item.prop] == undefined) {
    //                 getDataList(url).then((response) => {
    //                   // if (response.code == 200) {
    //                   this.tempDicts[item.prop] = deepClone(response.rows);
    //                   let tempDicts = JSON.parse(
    //                     sessionStorage.getItem("tempDicts")
    //                   );
    //                   tempDicts[item.prop] = deepClone(response.rows);
    //                   sessionStorage.setItem(
    //                     "tempDicts",
    //                     JSON.stringify(tempDicts)
    //                   );
    //                   formData[index].optionValue = response.rows;
    //                   if (response.rows && response.rows.length == 1) {
    //                     // console.log(response.rows)
    //                     this.form[item.prop] = response.rows[0].id;
    //                   }
    //                   // }
    //                 });
    //               }
    //             } else {
    //               this.getDicts(item.optionValue).then((response) => {
    //                 this.tempDicts[item.prop] = deepClone(response.data);
    //                 formData[index].optionValue = this.selectNormalizer(
    //                   response.data
    //                 );
    //               });
    //             }
    //           } else if (item.show && this.form.id) {
    //             getDataList(this.getUrl(item.show, this.form)).then(
    //               (response) => {
    //                 if (response.code == 200) {
    //                   item.optionValue = response.rows;
    //                 }
    //               }
    //             );
    //           }
    //         }
    //       }
    //     }
    //     if (item.componentType === "el-cascader") {
    //       let optionarr = item.optionValue.split("?");
    //       if (optionarr.length > 1) {
    //         this.optionNormalizer(optionData[optionarr[0]]);
    //         let typearr = [];
    //         optionData[optionarr[0]].forEach((titem) => {
    //           if (titem.value === parseInt(optionarr[1])) {
    //             typearr.push(titem);
    //             formData[index].optionValue = typearr;
    //           }
    //         });
    //       } else {
    //         formData[index].optionValue = this.optionNormalizer(
    //           optionData[item.optionValue]
    //         );
    //       }
    //     }
    //     if (item.componentType === "el-add-existing") {
    //       if (item.prop == "productName" || item.prop == "productCode") return;
    //       let appendid = this.$route.params.Id;
    //       if (this.$route.query.type.indexOf("pmswbs") > -1) {
    //         appendid = this.dataInfo.projectid;
    //       }
    //       let pageParams = eval("(" + item.show + ")");
    //       let type = pageParams.type;
    //       let geturl = pageParams.getUrl;
    //       if (geturl.indexOf("{") > -1) {
    //         if (this.tempDicts[item.prop + "-" + appendid]) {
    //           let tempDicts = JSON.parse(sessionStorage.getItem("tempDicts"));
    //           tempDicts[item.prop + "-" + appendid] = deepClone(
    //             this.tempDicts[item.prop + "-" + appendid]
    //           );
    //           item.optionValue = deepClone(
    //             tempDicts[item.prop + "-" + appendid]
    //           );
    //           sessionStorage.setItem("tempDicts", JSON.stringify(tempDicts));
    //         } else {
    //           geturl = this.getUrl(pageParams.getUrl, { projectId: appendid });
    //           getDataList(geturl).then((res) => {
    //             let tempDicts = JSON.parse(sessionStorage.getItem("tempDicts"));
    //             if (res.rows && res.rows.length > 0) {
    //               tempDicts[item.prop + "-" + appendid] = deepClone(res.rows);
    //               if (type == "split_tree_table") {
    //                 for (let i of res.rows) {
    //                   getDataList(this.getUrl(pageParams.expandUrl, i), {
    //                     loginUser:
    //                       sessionStorage.getItem("loginUser") ||
    //                       this.$store.state.user.userid,
    //                   }).then((response) => {
    //                     if (pageParams.expandUrl.indexOf("enovia") > -1) {
    //                       response = JSON.parse(response)
    //                     }
    //                     tempDicts[item.prop + "-" + appendid] = tempDicts[
    //                       item.prop + "-" + appendid
    //                     ].concat(response.rows);
    //                     item.optionValue = deepClone(
    //                       tempDicts[item.prop + "-" + appendid]
    //                     );
    //                     sessionStorage.setItem(
    //                       "tempDicts",
    //                       JSON.stringify(tempDicts)
    //                     );
    //                     this.tempDicts[item.prop + "-" + appendid] = deepClone(
    //                       tempDicts[item.prop + "-" + appendid]
    //                     );
    //                   });
    //                 }
    //               }else{
    //                 item.optionValue = deepClone(
    //                   tempDicts[item.prop + "-" + appendid]
    //                 );
    //                 sessionStorage.setItem(
    //                   "tempDicts",
    //                   JSON.stringify(tempDicts)
    //                 );
    //                 this.tempDicts[item.prop + "-" + appendid] = deepClone(
    //                   tempDicts[item.prop + "-" + appendid]
    //                 );
    //               }
    //             }
    //           });
    //         }
    //       } else {
    //         // geturl = this.getUrl(pageParams.getUrl);
    //         if (this.tempDicts[item.prop]==undefined) {
    //           getDataList(geturl).then((res) => {
    //             let tempDicts = JSON.parse(sessionStorage.getItem("tempDicts"));
    //             if (res.rows && res.rows.length > 0) {
    //               tempDicts[item.prop] = deepClone(res.rows);
    //               if (type == "split_tree_table") {
    //                 for (let i of res.rows) {
    //                   getDataList(this.getUrl(pageParams.expandUrl, i), {
    //                     loginUser:
    //                       sessionStorage.getItem("loginUser") ||
    //                       this.$store.state.user.userid,
    //                   }).then((response) => {
    //                     if (pageParams.expandUrl.indexOf("enovia") > -1) {
    //                       response = JSON.parse(response)
    //                     }
    //                     tempDicts[item.prop] = tempDicts[item.prop].concat(
    //                       response.rows
    //                     );
    //                     item.optionValue = deepClone(tempDicts[item.prop]);
    //                     sessionStorage.setItem(
    //                       "tempDicts",
    //                       JSON.stringify(tempDicts)
    //                     );
    //                     this.tempDicts[item.prop] = deepClone(tempDicts[item.prop]);
    //                   });
    //                 }
    //               }else{
    //                 item.optionValue = deepClone(tempDicts[item.prop]);
    //                 sessionStorage.setItem(
    //                   "tempDicts",
    //                   JSON.stringify(tempDicts)
    //                 );
    //                 this.tempDicts[item.prop] = deepClone(tempDicts[item.prop]);
    //               }
    //             }
    //           });
    //         } else {
    //           item.optionValue = deepClone(this.tempDicts[item.prop]);
    //           let tempDicts = JSON.parse(sessionStorage.getItem("tempDicts"));
    //           tempDicts[item.prop] = deepClone(this.tempDicts[item.prop])
    //           sessionStorage.setItem(
    //                 "tempDicts",
    //                 JSON.stringify(tempDicts)
    //               );
    //         }
    //       }
    //       // let formtype = pageParams.type;
    //       // getDataList(geturl).then(res=>{
    //       //   console.log(res)
    //       // })
    //     }
    //   });
    //   return formData;
    // },
    // /** 转换选项数据结构 */
    // optionNormalizer(data) {
    //   data.forEach((item, index) => {
    //     data[index] = {
    //       value: item.id,
    //       label: item.systemName ? item.description : item.name,
    //       parentid: item.parentid,
    //     };
    //   });
    //   return this.handleTree(data, "value");
    // },
    // /** 转换选项数据结构 */
    // selectNormalizer(data) {
    //   data.forEach((item, index) => {
    //     data[index] = {
    //       id: item.dictValue || item.id,
    //       description: item.dictLabel || item.name || item.forderName,
    //     };
    //   });
    //   return data;
    // },
  }
}
</script>

<style lang="scss" scoped>
.app-container {
  margin: 0;
  padding: 0;
  position: relative;
}
.collapesbutton {
  width: 14px;
  position: absolute;
  top: 0;
  bottom: 0;
  padding: 0;
  border: none;
  margin: auto 0;
  z-index: 2000;
}
.treeMenu {
  //background-color: #f8f8f8;
  height: 100%;
  position: relative;
}
.el-menu-item {
  border-bottom: 1px solid #dcdfe6;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.el-menu-item.is-active {
  background: #edf5fe;
  border-radius: 3px 3px 3px 3px;
  border-right: 3px solid #2064f6;
}
.treeMenu .el-tabs--border-card {
  height: calc(100% - 3px);
  // height: 100%;
  box-shadow: 0px 2px 2px 0px rgba(159, 162, 191, 0.05),
    0px 9px 16px 0px rgba(159, 162, 191, 0.18);
  border-radius: 4px 4px 4px 4px;
  overflow: auto;
  overflow: auto;
}
.app-container .head-container {
  padding-left: 5px;
  padding-right: 5px;
  border-top: 1px solid #d8d8d8;
}

.el-tabs__item {
  height: 30px;
  line-height: 30px;
}
.page-title {
  background: #fff;
  /*border: 1px solid #D8D8D8;*/
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
  white-space: nowrap;
  /*margin-bottom: 5px;*/
}
.headerContent {
  float: left;
  padding: 10px 0 10px;
  width: 100%;
}
.extendedHeader {
  display: block;
  line-height: 23px;
  white-space: nowrap;
}
.extendedHeader.name {
  font-size: 14px;
  // font-weight: bold;
  font-family: '3dsregular', Arial, Helvetica, sans-serif;
  max-width: 250px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  // text-align: center;
  padding: 0 5px;
}
.extendedHeader.content {
  font-size: 14px;
  max-width: 250px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  float: left;
}
.extendedHeader.fromTitle {
  font-size: 13px;
  width: 150px;
  vertical-align: middle;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.inline-block {
  display: inline-block;
  margin-right: 20px;
}
.infinite-list {
  list-style: none;
  padding: 5px;
  margin: 0;
}
.infinite-list-item {
  list-style: none;
  padding: 5px;
  margin: 0;
  background-color: #f8f8f8;
  border-bottom: 1px solid #d8d8d8;
  position: relative;
}
.infinite-list-item.selected {
  list-style: none;
  padding: 5px;
  margin: 0;
  background-color: #fff;
  border-bottom: 1px solid #d8d8d8;
  position: relative;
}
.el-dropdown {
  padding: 10px;
}
.mainContent {
  float: left;
  width: 100%;
  height: 100%;
}
.extendedMain {
  display: block;
  line-height: 23px;
  white-space: nowrap;
  border-bottom: #d8d8d8 solid 1px;
}
.extendedMain.name {
  font-size: 16px;
  font-weight: bold;
  font-family: '3dsregular', Arial, Helvetica, sans-serif;
  max-width: 250px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.extendedMain.content {
  font-size: 13px;
  width: 300px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  padding: 5px 0 5px 10px;
  border-right: 1px solid #ccc;
  margin-right: 12px;
}
.extendedMain.fromTitle {
  font-size: 13px;
  width: 150px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  padding: 5px 0 5px 10px;
  background-color: #f5f7fa;
}
.flex {
  display: flex;
}
.contextmenu {
  margin: 0;
  background: #fff;
  z-index: 3000;
  position: absolute;
  list-style-type: none;
  padding: 5px 0;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 400;
  color: #333;
  box-shadow: 2px 2px 3px 0 rgba(0, 0, 0, 0.3);
  li {
    margin: 0;
    padding: 7px 16px;
    cursor: pointer;
    &:hover {
      background: #eee;
    }
  }
}
//去掉最上级的before  after 即是去电最上层的连接线
/deep/ .el-tree > div {
  &::before {
    display: none;
  }
  &::after {
    display: none;
  }
}
.max-size {
  width: 100% !important;
  min-width: 100% !important;
  padding-left: 16px !important;
}
</style>
